#ifndef ImplMPO_H
#define ImplMPO_H

#include "PhoneOwnerImpl.h"
#include "Observer.h"
#include "TC.h"


class ImplMPO : public PhoneOwnerImpl, public Observer {
public:
	ImplMPO( Subject* s, string n, double c) 
		: PhoneOwnerImpl( n, c ) {

		number = n;
		cost = c; 
		sbj = s; 
		sbj->Attach(this); 	
	}

	~ImplMPO() { 
		sbj->Detach(this); 
	} 


	void Update (Subject* ChngSubject) { 
		if (ChngSubject == sbj ) {
			if (cost != ((TC*)ChngSubject)->getMobileCost()) {
				cost = ((TC*)ChngSubject)->getMobileCost();
				cout << "Mobile cost changed: " << cost << endl;
			}
			else if (((TC*)ChngSubject)->getUpgradeState())
				cout << number << " ,you can upgrade your mobile phone" << endl; 
		}
	} 

	bool getState() {
		return true;  // for upgrade notifier 
	}


	virtual void printOut() { 
	   cout << "Mobile Owner Number is:" << n << " and it's cost is: " << c << endl; 
	}

private:
	double cost;   // phone cost
	string number; // phone number
};


#endif
